package com.ctsi.ntedu.repository;

import com.ctsi.ntedu.domain.NteduRecord;
import com.ctsi.ntedu.domain.NteduRecordExample;
import java.util.List;

import com.ctsi.ntedu.domain.Overview;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

/**
 * @author ctsi-biyi-generator
*/
@Mapper
public interface NteduRecordRepository extends com.ctsi.ssdc.repository.BaseRepository<NteduRecord, Integer, NteduRecordExample> {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @SelectProvider(type=NteduRecordSqlProvider.class, method="countByExample")
    long countByExample(NteduRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @DeleteProvider(type=NteduRecordSqlProvider.class, method="deleteByExample")
    int deleteByExample(NteduRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @Delete({
        "delete from ntedu_record",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @Insert({
        "insert into ntedu_record (school_id, acc_nbr, ",
        "call_in, call_out, ",
        "complete, lose, ",
        "leave_word, dt, hour)",
        "values (#{schoolId,jdbcType=INTEGER}, #{accNbr,jdbcType=VARCHAR}, ",
        "#{callIn,jdbcType=INTEGER}, #{callOut,jdbcType=INTEGER}, ",
        "#{complete,jdbcType=INTEGER}, #{lose,jdbcType=INTEGER}, ",
        "#{leaveWord,jdbcType=INTEGER}, #{dt,jdbcType=DATE}, #{hour,jdbcType=INTEGER})"
    })
    @Options(useGeneratedKeys=true, keyProperty="id")
    int insert(NteduRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @InsertProvider(type=NteduRecordSqlProvider.class, method="insertSelective")
    @Options(useGeneratedKeys=true, keyProperty="id")
    int insertSelective(NteduRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @SelectProvider(type=NteduRecordSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="school_id", property="schoolId", jdbcType=JdbcType.INTEGER),
        @Result(column="acc_nbr", property="accNbr", jdbcType=JdbcType.VARCHAR),
        @Result(column="call_in", property="callIn", jdbcType=JdbcType.INTEGER),
        @Result(column="call_out", property="callOut", jdbcType=JdbcType.INTEGER),
        @Result(column="complete", property="complete", jdbcType=JdbcType.INTEGER),
        @Result(column="lose", property="lose", jdbcType=JdbcType.INTEGER),
        @Result(column="leave_word", property="leaveWord", jdbcType=JdbcType.INTEGER),
        @Result(column="dt", property="dt", jdbcType=JdbcType.DATE),
        @Result(column="hour", property="hour", jdbcType=JdbcType.INTEGER)
    })
    List<NteduRecord> selectByExample(NteduRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @Select({
        "select",
        "id, school_id, acc_nbr, call_in, call_out, complete, lose, leave_word, dt, hour",
        "from ntedu_record",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="school_id", property="schoolId", jdbcType=JdbcType.INTEGER),
        @Result(column="acc_nbr", property="accNbr", jdbcType=JdbcType.VARCHAR),
        @Result(column="call_in", property="callIn", jdbcType=JdbcType.INTEGER),
        @Result(column="call_out", property="callOut", jdbcType=JdbcType.INTEGER),
        @Result(column="complete", property="complete", jdbcType=JdbcType.INTEGER),
        @Result(column="lose", property="lose", jdbcType=JdbcType.INTEGER),
        @Result(column="leave_word", property="leaveWord", jdbcType=JdbcType.INTEGER),
        @Result(column="dt", property="dt", jdbcType=JdbcType.DATE),
        @Result(column="hour", property="hour", jdbcType=JdbcType.INTEGER)
    })
    NteduRecord selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @UpdateProvider(type=NteduRecordSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") NteduRecord record, @Param("example") NteduRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @UpdateProvider(type=NteduRecordSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") NteduRecord record, @Param("example") NteduRecordExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @UpdateProvider(type=NteduRecordSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(NteduRecord record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table ntedu_record
     *
     * @mbg.generated Fri Aug 06 15:41:13 CST 2021
     */
    @Update({
        "update ntedu_record",
        "set school_id = #{schoolId,jdbcType=INTEGER},",
          "acc_nbr = #{accNbr,jdbcType=VARCHAR},",
          "call_in = #{callIn,jdbcType=INTEGER},",
          "call_out = #{callOut,jdbcType=INTEGER},",
          "complete = #{complete,jdbcType=INTEGER},",
          "lose = #{lose,jdbcType=INTEGER},",
          "leave_word = #{leaveWord,jdbcType=INTEGER},",
          "dt = #{dt,jdbcType=DATE},",
          "hour = #{hour,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(NteduRecord record);

//    @Select({
//            "select",
//            "#{example.getDate().getEquals()} as date,SUM(complete) as tel_num_total,",
//            "SUM(call_in) as tel_num_true_total,SUM(lose) as tel_num_false_total,",
//            "SUM(leave_word) as message_total,SUM(call_out) as tel_out_total",
//            "from ntedy_record",
//            "where DATE_FORMAT(dt,'%Y-%m')= #{example.getDate().getEquals()}"
//    })
    @SelectProvider(type = NteduRecordSqlProvider.class, method = "selectByDate")
    @Results({
            @Result(column="date", property="date"),
            @Result(column="tel_num_total", property="telNumTotal"),
            @Result(column="tel_num_true_total", property="telNumTrueTotal"),
            @Result(column="tel_num_false_total", property="telNumFalseTotal"),
            @Result(column="message_total", property="messageTotal"),
            @Result(column="tel_out_total", property="telOutTotal")
    })
    List<Overview> selectByDate(NteduRecordExample example);


}